package com.hn658.base.message.managermq.container;

import org.springframework.jms.listener.DefaultMessageListenerContainer;

public class MqListenerContainer extends DefaultMessageListenerContainer {
	protected String name;
	protected String connectionFactoryName;
	protected String destinationName;
	protected String messageListenerName;
	protected String pubSubDomainName;
	protected String pubSubNoLocalName;
	protected String receiveTimeoutName;
	public MqListenerContainer(){
		
	}
	
	public MqListenerContainer(String name, String connectionFactoryName,
			String destinationName, String messageListenerName,
			String pubSubDomainName, String pubSubNoLocalName,
			String receiveTimeoutName) {
		super();
		this.name = name;
		this.connectionFactoryName = connectionFactoryName;
		this.destinationName = destinationName;
		this.messageListenerName = messageListenerName;
		this.pubSubDomainName = pubSubDomainName;
		this.pubSubNoLocalName = pubSubNoLocalName;
		this.receiveTimeoutName = receiveTimeoutName;
	}

	public String getBeanXml(){
		 StringBuffer buf = new StringBuffer();  
		 buf.append("<bean id=\""+name+"\" class=\"com.hn658.base.message.managermq.container.MqListenerContainer\">")
		 	.append("<property name=\"connectionFactory\" ref=\""+connectionFactoryName+"\"></property>")
		 	.append("<property name=\"destination\" ref=\""+destinationName+"\"></property>")
		 	.append("<property name=\"messageListener\" ref=\""+messageListenerName+"\"></property>")
		 	.append("<property name=\"pubSubDomain\" value=\""+pubSubDomainName+"\" />")
		 	.append("<property name=\"pubSubNoLocal\" value=\""+pubSubNoLocalName+"\" />")
		 	.append("<property name=\"receiveTimeout\" value=\""+receiveTimeoutName+"\" />")
		 	.append("</bean>");
		 return buf.toString();
	}
	/** 
     * 生成完整的xml字符串 
     * @return 
     */  
    public String getXml(){  
        StringBuffer buf = new StringBuffer();  
        buf.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")  
            .append("<beans xmlns=\"http://www.springframework.org/schema/beans\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"")  
            .append("       xmlns:p=\"http://www.springframework.org/schema/p\" xmlns:aop=\"http://www.springframework.org/schema/aop\"")  
            .append("       xmlns:context=\"http://www.springframework.org/schema/context\" xmlns:jee=\"http://www.springframework.org/schema/jee\"")  
            .append("       xmlns:tx=\"http://www.springframework.org/schema/tx\"")  
            .append("       xsi:schemaLocation=\"")  
            .append("           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd")  
            .append("           http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd")  
            .append("           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd")  
            .append("           http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd")  
            .append("           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd\">")  
            .append(getBeanXml())  
            .append("</beans>");  
        return buf.toString();  
    }
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}

	public String getConnectionFactoryName() {
		return connectionFactoryName;
	}

	public void setConnectionFactoryName(String connectionFactoryName) {
		this.connectionFactoryName = connectionFactoryName;
	}

	public String getDestinationName() {
		return destinationName;
	}

	public void setDestinationName(String destinationName) {
		this.destinationName = destinationName;
	}

	public String getMessageListenerName() {
		return messageListenerName;
	}

	public void setMessageListenerName(String messageListenerName) {
		this.messageListenerName = messageListenerName;
	}

	public String getPubSubDomainName() {
		return pubSubDomainName;
	}

	public void setPubSubDomainName(String pubSubDomainName) {
		this.pubSubDomainName = pubSubDomainName;
	}

	public String getPubSubNoLocalName() {
		return pubSubNoLocalName;
	}

	public void setPubSubNoLocalName(String pubSubNoLocalName) {
		this.pubSubNoLocalName = pubSubNoLocalName;
	}

	public String getReceiveTimeoutName() {
		return receiveTimeoutName;
	}

	public void setReceiveTimeoutName(String receiveTimeoutName) {
		this.receiveTimeoutName = receiveTimeoutName;
	}
    
}
